﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HCQ2_Model.Data;
using HCQ2_Model.Pay;
using HCQ2_Model.ViewModel;
using HCQ2_Model.WeiXinApiModel.Model;

namespace HCQ2_IBLL
{
    /// <summary>
    /// 订单相关
    /// </summary>
    public partial interface IN_OrderBLL
    {
        /// <summary>
        /// 获取订单列表
        /// </summary>
        /// <param name="orderListParams"></param>
        /// <returns></returns>
        OperationResult<TableModel<List<OrderListModel>>> ListOrderList(GetOrderListParams listParams);

        /// <summary>
        /// 获取父订单号列表
        /// </summary>
        /// <param name="listParams"></param>
        /// <returns></returns>
        OperationResult<GetParentOrderListTableModel> ListParentOrderList(GetParentOrderListParams listParams);

        /// <summary>
        /// 获取订单详细
        /// </summary>
        /// <param name="detailedParams"></param>
        /// <returns></returns>
        OperationResult<GetOrderDetailedModel> GetOrderDetailed(GetOrderDetailedParams detailedParams);

        /// <summary>
        /// 获取PC订单列表
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <returns></returns>
        OperationResult<TableModel> ListOrderList(GetPcOrderListParams listParams);

        /// <summary>
        /// 获取订单支付金额
        /// </summary>
        /// <param name="paymentAmountParams">请求参数</param>
        /// <returns></returns>
        OperationResult<PaymentAmountModel> GetPaymentAmount(PaymentAmountParams paymentAmountParams);

        /// <summary>
        /// 提交商品信息创建订单;订单状态：待付款
        /// </summary>
        /// <param name="submitOrderParams">下单参数</param>
        /// <returns></returns>
        OperationResult<string> CreateOrder(SubmitOrderParams submitOrderParams);

        /// <summary>
        /// 未付款订单返回微信支付
        /// </summary>
        /// <param name="ddParams"></param>
        /// <returns></returns>
        OperationResult<WebChartPreOrderPayDDQRCodeResultModel> WebChartQRCodePayOrder(WebChartQRCodePayOrderParams ddParams);

        /// <summary>
        /// 付款订单
        /// </summary>
        /// <param name="paymentParams">订单信息</param>
        /// <returns></returns>
        OperationResult<PayOrderModel> PayOrder(PaymentParams paymentParams);

        /// <summary>
        /// 确认订单
        /// </summary>
        /// <param name="cancelConfirmParams"></param>
        /// <returns></returns>
        OperationResult ConfirmOrder(OrderConfirmParams cancelConfirmParams);
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="orderCancelParams"></param>
        /// <returns></returns>
        OperationResult CancelOrder(OrderCancelParams orderCancelParams);
        /// <summary>
        /// 获取PC订单列表导出数据源
        /// </summary>
        /// <param name="listParams"></param>
        /// <returns></returns>
        DataTable ListOrderListExpData(GetPcOrderListParams listParams);

        /// <summary>
        /// 获取订单数量
        /// </summary>
        /// <param name="orderState"></param>
        /// <returns></returns>
        int GetOrderTotal(GetOrderTotalParams getOrderTotalParams);

        /// <summary>
        /// 检查 商品是否已经购买并且有效
        /// </summary>
        /// <param name="commodityIds">商品ID集合</param>
        /// <param name="userId">当前用户ID</param>
        /// <returns>返回已购买商品名称</returns>
        IList<string> CheckCommodityPay(List<int> commodityIds, int userId);

        /// <summary>
        ///  获取微信小程序的openid
        /// </summary>
        /// <param name="code">临时登录凭证</param>
        /// <returns></returns>   
        /// <remarks>
        /// 修改记录：
        /// 2021-10-7：添加参数webChartAppId，如果不为空，那么去数据库中获取对应的密钥进行openId的获取
        /// </remarks>
        OperationResult<ChartUser> GetWebChartOpenId(string code, string webChartAppId = null);

        /// <summary>
        /// 调用付款系统，执行调用微信统一下单接口
        /// </summary>
        /// <param name="orderParams"></param>
        /// <param name="appId">小程序的appId</param>
        /// <returns></returns>
        OperationResult<WeChatUnifiedOrderModel> SystemPay(WeChatUnifiedOrderParams orderParams, string appId = null);

        /// <summary>
        /// 微信小程序扫码支付，创建系统内部订单生成单号返回
        /// </summary>
        /// <param name="order2Params">创建订单参数</param>
        /// <returns>返回单号</returns>
        OperationResult<CreateOrder2Model> CreateOrder2(CreateOrder2Params order2Params);

        /// <summary>
        /// VR设备购买时间，微信小程序扫码支付下单，内部调用3个接口分别是：
        /// <see cref="GetWebChartOpenId(string)"/>获取微信的openid、
        /// <see cref="CreateOrder2(CreateOrder2Params)"/>系统内部下单生成单号、
        /// <see cref="SystemPay(WeChatUnifiedOrderParams)"/>调用微信统一下单接口
        /// </summary>
        /// <param name="orderParams">下单参数</param>
        /// <returns>返回微信支付的预付单信息</returns>
        OperationResult<WeChatUnifiedOrderModel> WebChartPreOrderPay(CreateOrder2Params orderParams);

        /// <summary>
        /// 度度圈，小程序支付下单
        /// <see cref="GetWebChartOpenId(string)"/>获取微信的openid、
        /// <see cref="CreateOrder(SubmitOrderParams)"/>系统内部下单生成单号、
        /// <see cref="SystemPay(WeChatUnifiedOrderParams)"/>调用微信统一下单接口
        /// </summary>
        /// <param name="ddParams"></param>
        /// <returns>返回微信支付的预付单信息</returns>
        OperationResult<WeChatUnifiedOrderModel> WebChartPreOrderPayDD(WebChartPreOrderPayDDParams ddParams);

        /// <summary>
        /// 度度圈网页，微信扫码支付
        /// <see cref="CreateOrder(SubmitOrderParams)"/>系统内部下单生成单号、
        /// <see cref="SystemPay(WeChatUnifiedOrderParams)"/>调用微信统一下单接口得到微信二维码
        /// </summary>
        /// <param name="ddParams"></param>
        /// <returns>返回微信支付的预付单信息</returns>
        OperationResult<WebChartPreOrderPayDDQRCodeResultModel> WebChartPreOrderPayDDQRCode(WebChartPreOrderPayDDQRCodeParams ddParams);

        /// <summary>
        ///  获取用户-购买商品有效期截止时间
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="fileId"></param>
        /// <returns></returns>
        string GetPayEndTime(int userId, int fileId);

        /// <summary>
        /// 确认发货
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        OperationResult ConfirmSendOutGoods(ConfirmSendOutGoodsParams param);

        /// <summary>
        /// 确认收货
        /// </summary>
        /// <param name="param">请求参数</param>
        /// <returns></returns>
        OperationResult ConfirmReceivingGoods(ConfirmReceivingGoodsParams param);

        /// <summary>
        /// 获取我的订单统计
        /// </summary>
        /// <param name="param">请求参数</param>
        /// <returns></returns>        
        OperationResult<OrderStatisticsModel> OrderStatistics(OrderStatisticsParams param);

        /// <summary>
        /// 更新订单备货状态
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        OperationResult UpdateStorageStatus(UpdateStorageStatusParams param);

        /// <summary>
        /// 更新订单接单人信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        OperationResult UpdateOrderReceivingUser(UpdateOrderReceivingUserParams param);

        /// <summary>
        /// 按父订单号分组合计订单数量
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        OperationResult GetParentGroupOrderTotal(GetParentGroupOrderTotalParams param);

        /// <summary>
        /// 获取店铺订单统计<br/>
        /// 需求《度度圈需求规格-订单统计-20220120.docx》添加
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        OperationResult<GetStoreOrderStatModel> GetStoreOrderStat(GetStoreOrderStatParams param);

        /// <summary>
        /// 获取店铺商品销量统计<br/>
        /// 需求《度度圈需求规格-订单统计-20220120.docx》添加
        /// </summary>
        /// <param name="parsm"></param>
        /// <returns></returns>
        OperationResult<List<GetStoreGoodsStatModel>> GetStoreGoodsStat(GetStoreGoodsStatParams param);

        /// <summary>
        /// 获取订单状态
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns></returns>
        OperationResult GetOrderState(GetOrderStateParams param);
    }
}
